package com.gao.controller;

import com.gao.service.PayMentService;
import commomresult.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.web.bind.annotation.*;
import pojo.Payment;

import javax.annotation.Resource;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/pay")
@EntityScan
@Slf4j
public class PayMentController {

    @Resource
    private PayMentService payMentService ;

    @PostMapping("/payment/create")
    public CommonResult<Payment> create(@RequestBody Payment dept) {
        int i = payMentService.create(dept);
//        log.info("***************插入成功*******" + i);
        if (i > 0) {
            return new CommonResult<Payment>("200", "插入数据库成功" + dept);
        } else {
            return new CommonResult<Payment>("400", "插入数据库失败", null);
        }
    }

    @RequestMapping("queryById/{id}")
    public CommonResult<Payment> getPay(@PathVariable Integer id) {
        Payment payment = payMentService.queryById(id);
        System.out.println(payment);
        return new CommonResult<>("10000", "获取成功！", payment) ;
    }
}
